package com.pxmeta.skill.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Lists;
import com.pxmeta.skill.entity.SkillCertificationForm;
import com.pxmeta.skill.mapper.SkillCertificationFormMapper;
import com.pxmeta.skill.service.ISkillCertificationFormService;
import com.pxmeta.skill.service.ISkillFormItemService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@RequiredArgsConstructor
public class SkillCertificationFormServiceImpl extends ServiceImpl<SkillCertificationFormMapper, SkillCertificationForm> implements ISkillCertificationFormService {
    private final ISkillFormItemService formItemService;

    @Override
    public List<SkillCertificationForm> getBySkillId(Integer skillId) {
        LambdaQueryWrapper<SkillCertificationForm> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(SkillCertificationForm::getSkillId, skillId)
                .orderByAsc(SkillCertificationForm::getType);
        return this.list(wrapper);
    }

    @Override
    public void addForm(Integer skillId,List<Integer> stepIdx) {

        List<String> names = Lists.newLinkedList();
        List<String> values = Lists.newLinkedList();



        for (int i = 0; i < 9; i++) {
            int type = i+1;
            if (stepIdx.contains(type)){
                continue;
            }
            SkillCertificationForm form = new SkillCertificationForm();
            form.setType(type);
            form.setSkillId(skillId);
            if (type==1){
                form.setName("上传图片");
                form.setPlaceholder("请上传与你技能等级相符的游戏截图，男星耀以上，女铂金以上，大小不超过5M（不要放自拍！！）");
                form.setStep("one");
                form.setFormType(1);
                this.save(form);
            }
            if (type==2){
                names.add("黑铁");
                names.add("青铜");
                names.add("白银");
                names.add("黄金");
                names.add("铂金");
                names.add("钻石");
                names.add("超凡");
                names.add("神话");
                names.add("赋能");

                form.setName("技能等级");
                form.setPlaceholder("必须与技能图一致");
                form.setStep("one");
                form.setFormType(2);
                this.save(form);
                formItemService.saveBatchByFromId(names,null,form.getId());
            }
            if (type==3){
                form.setName("上传语音");
                form.setPlaceholder("录制一段自我介绍语音（例如你的音色、曲风等）");
                form.setStep("one");
                form.setFormType(3);
                this.save(form);
            }
            if (type==4){
                form.setName("技能介绍");
                form.setPlaceholder("示例：（主打位置、声音特点、技术特点）\n" +
                        "1、一个声音很甜、很认真、不混单的小辅助，只想做你的专属小精灵，粘着你，守护着你~\n" +
                        "2、主玩打野，全能补位，广州第20玄策，技术娱乐陪，心态好，快找我下单吧~");
                form.setStep("one");
                form.setFormType(4);
                this.save(form);
            }
            if (type==5){
                names.clear();
                values.clear();
                values.add("5");
                values.add("6");
                values.add("7");
                values.add("8");
                values.add("9");
                values.add("10");

                names.add("5币");
                names.add("6币");
                names.add("7币");
                names.add("8币");
                names.add("9币");
                names.add("10币");
                form.setName("接单单价");
                form.setPlaceholder("");
                form.setStep("two");
                form.setFormType(5);
                this.save(form);
                formItemService.saveBatchByFromId(names,values,form.getId());

            }
            if (type==6){
                form.setName("游戏区服");
                form.setPlaceholder("");
                form.setStep("two");
                form.setFormType(6);
                this.save(form);
            }
            if (type==7){
                form.setName("擅长位置");
                form.setPlaceholder("");
                form.setStep("two");
                form.setFormType(7);
                this.save(form);
            }
            if (type==8){
                form.setName("优惠方式");
                form.setPlaceholder("无");
                form.setStep("two");
                form.setFormType(5);
                this.save(form);
            }
            if (type==9){
                form.setName("游戏区服");
                form.setPlaceholder("无");
                form.setStep("two");
                form.setFormType(5);
                this.save(form);
            }


        }
    }

    public static void main(String[] args) {
        for (int i = 0; i < 9; i++) {
            System.out.println(i);
        }
    }
}
